﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BankSystem
{
    internal class Account
    {
        protected String _accountNumber;
        protected String _password;
        protected int _balance;

        public Account(string accountNumber, string password)
        {
            AccountNumber = accountNumber;
            Password = password;
        }

        public String AccountNumber {
            get { return _accountNumber; } 
            set { _accountNumber = value; } 
        }

        public String Password
        {
            get { return _password; }
            set { _password = value; }
        }

        public int Balance
        {
            get => _balance;
            set { _balance = value; }
        }

        public String this[int index] 
        {
            get
            {
                if (index == 0)
                {
                    return AccountNumber;
                }
                else if(index == 1){ 
                    return Password;
                }else if(index == 2)
                {
                    return Balance.ToString();
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
            }
        }

        public String AccountInfo()
        {
            return "该账号是普通账号，账号是 " + AccountNumber + "\n" +
                "余额为：" + Balance; 
        }

        public virtual String foo()
        {
            return "父类中的虚函数";
        }
    }
}
